<template>
	<view class="container">
		<view class="list">
			<view class="item bg-fff" v-for="(item,index) in orderList" :key="index">
				<view class="item-shop flex-space-between">
					<view class="flex-align-center">
						<view class="item-shop-name">订单号：{{item.orderMaster.order_no?item.orderMaster.order_no:'无'}}</view> <view class="first" v-if="item['first_order']">首单</view>
					</view>
				</view>
				<view class="item-total flex-space-between">
					<view>
						<text class="ctime">{{item.create_time}}</text>
					</view>
					<view>订单额：<text>￥{{item.pay_price}}</text></view>
				</view>
				<view class="item-total-second flex-space-between">
					<view>
						<text class="ctime">ID:{{item.user&&item.user.user_id}}({{item.user&&item.user.nickName}})</text>
					</view>
					<view></view>
				</view>
			</view>
		</view>
		
		<view v-if="orderList.length > 0">
			<b-u-loadmore :status="loadmoreStatus"></b-u-loadmore>
		</view>
		<view v-else style="padding-top: 100rpx;">
			<u-empty text="暂无数据" mode="data"></u-empty>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				orderList: [],
				pageForm: {
					type:0,
					page: 1,
					pay_source: 'wx',
					list_rows: 10,
				},
				loadmoreStatus: 'nomore',
			}
		},
		onLoad(options) {
			this.pageForm.type = options.dataType;
			if(this.pageForm.type==1){
				uni.setNavigationBarTitle({
					title: '当月推广订单列表'
				})
			}
		},
		onShow() {
			this.getHttp();
		},
		onReachBottom() {
			if(this.loadmoreStatus == 'nomore') {
				return;
			}
			this.pageForm.page++;
			this.getInviteList();
		},
		methods: {
			handleInvoice(item) {
				this.jump('/pages/mine/invoice/issue?order_id='+item.order_id+'&shop_supplier_id='+item.supplier.shop_supplier_id);
			},
			jump(url) {
				uni.navigateTo({
					url: url
				})
			},
			getInviteList() {
				this.loadmoreStatus = 'loading';
				uni.$u.api.getInviteList(this.pageForm).then(res => {
					this.orderList = this.orderList.concat(res.data);
					this.loadmoreStatus = 'loadmore';
					if(this.orderList.length  == res.total) {
						this.loadmoreStatus = 'nomore';
					}
				})
			},
			getHttp() {
				this.pageForm.page = 1;
				this.orderList = [];
				this.getInviteList();
			},
		},
	}
</script>

<style lang="scss" scoped>
	.container {
		.first{
			padding:5rpx 10rpx;
			background-color: #BB0024;
			color: #fff;
			border-radius: 10rpx;
			margin-left: 10rpx;
		}
		.tabs {
			position: fixed;
			top: 0;
			left: 0;
			z-index: 9;
			width: 100%;
		}
		
		.tabs-placeholder {
			height: 80rpx;
		}
		
		.list {
			padding: 30rpx;
			
			.item {
				padding: 26rpx;
				border-radius: 16rpx;
				margin-bottom: 24rpx;
				
				.item-shop-name {
					font-size: 28rpx;
					font-weight: bold;
					color: #111111;
				}
				
				.item-shop-status {
					font-size: 24rpx;
					color: $uni-color-theme;
				}
				
				.product-item {
					margin-top: 24rpx;
				
					.product-item-image {
						width: 128rpx;
						height: 128rpx;
					}
				
					.product-item-con {
						margin-left: 16rpx;
						flex: 1;
				
						.product-item-name {
							width: 460rpx;
							font-size: 28rpx;
							color: #111111;
						}
				
						.product-item-suk {
							font-size: 24rpx;
							color: #999999;
							margin-bottom: 10rpx;
						}
				
						.product-item-num {
							font-size: 24rpx;
							color: #999999;
						}
				
						.product-item-price {
							font-size: 28rpx;
							color: $uni-color-theme;
						}
					}
				}
				
				.item-total {
					margin-top: 34rpx;
					border-top: 1px solid rgba(225, 225, 225, 0.7);
					padding-top: 20rpx;
					// text-align: right;
					font-size: 28rpx;
					color: #111111;
					
					text {
						color: $uni-color-theme;
						font-weight: bold;
					}
					.ctime{
						color: #999;
						font-weight: normal;
					}
				}
				.item-total-second {
					margin-top: 34rpx;
					// text-align: right;
					font-size: 28rpx;
					color: #111111;
					
					text {
						color: $uni-color-theme;
						font-weight: bold;
					}
					.ctime{
						color: #999;
						font-weight: normal;
					}
				}
				.item-buttons {
					margin-top: 20rpx;
					justify-content: flex-end;
				}
			}
		}
	}
</style>
